<?php
class Form_PasswordEdit extends Zend_Form
{
    public function __construct ()
    {
        $this->setName('form_password_edit');
        parent::__construct();
        $password = new Zend_Form_Element_Password('password');
        $password->setLabel('Пароль*')
            ->setRequired(true)
            ->addValidator('NotEmpty');
        //add validator to check if two fields password are identical
        $identValidator = new Zend_Validate_Identical($_POST['password']);
        $identValidator->setMessages(
        array(
        'notSame' => 'Passwords are not same', 
        'missingToken' => 'Passwords are not same'));
        $password_repeat = new Zend_Form_Element_Password('password_repeat');
        $password_repeat->setLabel('Password repeat*')
            ->setRequired(true)
            ->addValidator('NotEmpty')
            ->addValidator($identValidator);
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Change');
        $this->addElements(array($password, $password_repeat, $submit));
    }
}
?>
